package leetcode_600;

import java.util.ArrayList;
import java.util.List;

/**
 *@author 周杨 
 *NaryTreePostorderTraversal_590 后序遍历一颗多叉树
 *describe:递归即可 AC 74%
 *2018年9月17日 上午11:02:24
 */
public class NaryTreePostorderTraversal_590 {
	
	class Node {
	    public int val;
	    public List<Node> children;

	    public Node() {}

	    public Node(int _val,List<Node> _children) {
	        val = _val;
	        children = _children;
	    }
	 }
	 public List<Integer> postorder(Node root) {
	        List<Integer> res=new ArrayList<Integer>();
	        if(root==null)
	        	return res;
	        help(root,res);
	        return res;
	 }
	private void help(Node root, List<Integer> res) {
		 for(Node node:root.children)
			 help(node,res);
		 res.add(root.val);
	}
}
